/**
* App.js main de aplicativo Sencha Touch.
* Aqui se declaran el modelo-vista-controlar utilizados
* en el aplicativo.
*/
var myVersion = '1.2.7.2.2.4.9';

Ext.Loader.setPath({
    'Ext': 'sdk/src'
});

Ext.Loader.setConfig({ enabled: true });
//</debug>

Ext.application({
    name: 'entgpv11',
    glossOnIcon: false,

    requires: [
        "Ext.APP_GLOBAL",
        "Ext.MessageBox",
		"Ext.chart",
        "Ext.data.TreeStore"
        //,"Ext.History"
    ],
    viewport: {
        autoMaximize: false
    },
    models: [
            "Login",
            "Note",
            "Images",
            "Filter",
            "ListVideo",
            "Region",
            "File",
            "Avance"
            ],
    stores: [
	         "Images",
	         "Notes",
             "Filter",
             "ListVideo",
             "Region",
             "File"
            ],
    controllers: [
			"Main",
			"Notes",
			"Device",
            "Add"
			],
    views: [
	        "MainContainer",
	        "ImageCamera",
			"Details",
			"MenuUser00",
			"MenuUser01",
			"MenuUser02"
		  ],

    icon: {
        57: 'resources/icons/Icon.png',
        72: 'resources/icons/Icon~ipad.png',
        114: 'resources/icons/Icon@2x.png',
        144: 'resources/icons/Icon~ipad@2x.png'
    },

    phoneStartupScreen: 'resources/loading/Homescreen.png',
    tabletStartupScreen: 'resources/loading/Homescreen~ipad.png',

    launch: function () {
        try {
            // Destroy the #appLoadingIndicator element
            Ext.fly('appLoadingIndicator').destroy();
            this.initialiseHistory();
            var mainContainer = {
                xtype: "maincontainer",
                versionString: myVersion
            };
           Ext.Viewport.add([mainContainer]);
         


        } catch (ex) {
            APP_GLOBAL.SetLog(' launch::' + ex);
        }
    },
    /**
    * Creates the necessary DOM elements required for Ext.History to manage state
    * Sets up a listener on Ext.History's change event to fire this.handleHistoryChange
    */
    initialiseHistory: function () {
        //        this.historyForm = Ext.getBody().createChild({
        //            tag: 'form',
        //            action: '#',
        //            cls: 'x-hidden',
        //            id: 'history-form',
        //            children: [
        //                      {
        //                          tag: 'div',
        //                          children: [
        //                          {
        //                              tag: 'input',
        //                              id: Ext.History.fieldId,
        //                              type: 'hidden'
        //                          },
        //                          {
        //                              tag: 'iframe',
        //                              id: Ext.History.iframeId
        //                          }
        //                        ]
        //                      }
        //                    ]
        //        });
        //initialize History management
        //Ext.History.init();
        //Ext.History.on('change', this.handleHistoryChange, this);
        //http://edspencer.net/2009/01/using-exthistory.html
        //Ext.History.add("products");
    },
    /**
    * @param {String} token The url token which has just been navigated to
    * (e.g. if we just went to http://myurl.com/#someurl, token would be 'someurl')
    */
    handleHistoryChange: function (token) {
        //        var token = token || "";
        //        switch (token) {
        //            case 'products': this.showProductsGrid(); break;
        //            case 'products/edit/1': this.showProductEditForm(1); break;
        //            case '':                //nothing after the #, show a default view
        //        }
    },

    showProductsGrid: function () {
        //some logic to display the grid, depending on how your app is structured
    },

    showProductEditForm: function (product_id) {
        //displays the product edit form for the given product ID.
    }

});
